import { getReqHotSongCat,getReqHotSong } from '../../service/music'
Page({
  data: {
    songMenus: []
  },
  onLoad() {
    this.fetchHotSongCat()
  },
  async fetchHotSongCat() {
    const res = await getReqHotSongCat()
    const tags = res.tags
    // 根据tag去获取歌单
    const newMenuList = []
    for(const tag of tags) {
      const promise = getReqHotSong(tag.name)
      newMenuList.push(promise)
    }

    // 获取到所有数据后  执行一次this.setData
    Promise.all(newMenuList).then(res=> {
      this.setData({songMenus: res})
    })
  }
})